package com.labichaoka.chaoka.ui.baseinfo.hand;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.IDCardRequest;
import com.labichaoka.chaoka.entity.IDCardResponse;
import com.labichaoka.chaoka.entity.RealNameRequest;
import com.labichaoka.chaoka.utils.ToastUtils;

/**
 * Created by ruan on 2018/8/8.
 */

public class HandImgPresenterImpl implements HandImgPresenter,HandImgInteractor.OnUploadFinishedListener{
    private HandImgInteractor interactor;
    private HandImgView handImgView;

    public HandImgPresenterImpl(HandImgInteractor imgInteractor,HandImgView v) {
        this.interactor=imgInteractor;
        this.handImgView=v;
    }

    @Override
    public void upload(IDCardRequest request) {
        if (handImgView!=null){
            handImgView.showProgress();
        }
        interactor.uploadFile(request,this);
    }

    @Override
    public void queryIDCard() {
        if (handImgView!=null){
            handImgView.showProgress();
        }
        interactor.onQueryIDCard(this);
    }

    @Override
    public void resetIdCard() {
        if (handImgView!=null){
            handImgView.showProgress();
        }
        interactor.resetCardId(this);
    }

    @Override
    public void setRealName(RealNameRequest request) {
        if (handImgView!=null){
            handImgView.showProgress();
        }
        interactor.resetRealName(request,this);
    }

    @Override
    public void onDestroy() {
        interactor=null;
    }

    @Override
    public void onUploadSuccessed(BaseResponse response) {
        handImgView.hideProgress();
        handImgView.goNext();
    }

    @Override
    public void onUploadFailed() {
        handImgView.hideProgress();
    }

    @Override
    public void onQueryIDCardSuccessed(IDCardResponse response) {
        handImgView.hideProgress();
        handImgView.queryIDCard(response);
    }

    @Override
    public void onQueryIDCardFailed() {
        handImgView.hideProgress();
    }

    @Override
    public void onResetRealNameSuccessed(BaseResponse response) {
        handImgView.hideProgress();
        handImgView.resetRealName(response);
    }

    @Override
    public void onResetRealNameFailed() {
        handImgView.hideProgress();
    }

    @Override
    public void onResetCardIdSucc(BaseResponse response) {
        handImgView.hideProgress();
        handImgView.resetIdCard(response);
    }

    @Override
    public void onResetCardIdFailed() {
        handImgView.hideProgress();
    }
}
